﻿@using Lib.core;
@using Lib.helper;

@using Bll;
@using Model;
@using Model.Sys;
@using Hiwjcn.Web.Models.Link;
@using WebLogic.Model.User;
@{
    Layout = null;

    var model = ViewData["role"] as RoleModel;
    if (model == null) { model = new RoleModel(); }
}

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- header page -->
    @Html.Partial(IncludePath("header"))
</head>

<body>
    @Html.Partial(IncludePath("body_top"))

    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <form id="fm">
                    <table class="table table-responsive">
                        <tbody>
                            <tr style="display:none;">
                                <td style="width:30%;"></td>
                                <td style="width:70%"></td>
                            </tr>
                            <tr style="display:none;">
                                <td>
                                    <input type="hidden" name="id" value="@(model.RoleID)" />
                                </td>
                            </tr>
                            <tr>
                                <td>名称</td>
                                <td>
                                    <input type="text" class="form-control" name="name" value="@(model.RoleName)" />
                                </td>
                            </tr>
                            <tr>
                                <td>描述</td>
                                <td>
                                    <input class="form-control" name="desc" value="@(model.RoleDescription)" />
                                </td>
                            </tr>
                            <tr>
                                <td>注册时自动分配</td>
                                <td>
                                    <select class="form-control" name="auto" data-value="@(model.AutoAssignToUserWhenRegistered)">
                                        <option value="false">否</option>
                                        <option value="true">是</option>
                                    </select>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="center">
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            var form = $('#fm');
            form.submit(function () {
                var data = $(this).serializeArray();
                postJson('/admin/permission/saveroleaction/', data, function (res) {
                    if (res && res.success) {
                        alert('保存成功');
                        reload_parent();
                    }
                    else {
                        alert(res.msg);
                    }
                });
                return false;
            });
        });
    </script>

    @Html.Partial(IncludePath("body_bottom"))
</body>
</html>
